/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.ufps.cuatro.modelo.asistente.libre.wizard;

import com.ufps.cuatro.controlador.render.UtilRender;
import com.ufps.cuatro.util.wizard.WizardPanelDescriptor;
import com.ufps.cuatro.vistas.asistente.libre.wizard.JPanelWizardLibreSelectElements;
import javax.swing.event.ListDataEvent;
import javax.swing.event.ListDataListener;

/**
 *
 * @author Carlos A. Torres C. 
 */
public class JPanelWizardLibreSelectElementsDescriptor extends WizardPanelDescriptor implements ListDataListener{
    
    public static final String IDENTIFIER = "SELECT_ELEMENTS";
    
    private JPanelWizardLibreSelectElements objPanel;
    
    public JPanelWizardLibreSelectElementsDescriptor() {
//      if(objPanel != null){
            //super(IDENTIFIER, new JPanelWizardLibreSelectElements());
            objPanel = new JPanelWizardLibreSelectElements(JPanelWizardLibreSelectElementsDescriptor.this);
            objPanel.addListDataListener(JPanelWizardLibreSelectElementsDescriptor.this);

            setPanelDescriptorIdentifier(IDENTIFIER);
            setPanelComponent(objPanel);
//        }
//       else{
//            UtilRender.printlnConsole("Objeto Panel Nulo.", UtilRender.ACTION_NORMAL, false);            
//        }
    }
    
    @Override
    public Object getNextPanelDescriptor() {
        return JPanelWizardLibreSelectConfigFinishDescriptor.IDENTIFIER;
    }
    
    @Override
    public Object getBackPanelDescriptor() {
        return null;
    }
    
    @Override
    public void aboutToDisplayPanel() {
//       try{
            setNextButtonAccordingToListEmpty();
//        }catch(java.lang.NullPointerException ex){}
    }
    
    public void setNextButtonAccordingToListEmpty() {
//      if(objPanel != null){
            if (objPanel.isListEmpty()){
                 getWizard().setNextFinishButtonEnabled(false);             
             }
             else{
                 getWizard().setNextFinishButtonEnabled(true);             
             }           
//      }else{
//            UtilRender.printlnConsole("Objeto Panel Nulo.", UtilRender.ACTION_NORMAL, false);            
//        }
    }

    public void intervalAdded(ListDataEvent e) {
//       if(e != null){ 
            setNextButtonAccordingToListEmpty();
//        }
    }

    public void intervalRemoved(ListDataEvent e) {
//       if(e != null){
        setNextButtonAccordingToListEmpty();
//        }
    }

    public void contentsChanged(ListDataEvent e) {
        //Nada
    }
    
}
